package com.aiplatform.service.AttractionsService.impl;

import com.aiplatform.dao.AttractionsDao;
import com.aiplatform.pojo.domain.Attractions;
import com.aiplatform.service.AttractionsService.AttractionsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Attractions)表服务实现类
 *
 * @author makejava
 * @since 2022-03-24 17:11:15
 */
@Service("attractionsService")
public class AttractionsServiceImpl implements AttractionsService {
    @Resource
    private AttractionsDao attractionsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param attractionsId 主键
     * @return 实例对象
     */
    @Override
    public Attractions queryById(Integer attractionsId) {
        return this.attractionsDao.queryById(attractionsId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Attractions> queryAllByLimit(int offset, int limit) {
        return this.attractionsDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param attractions 实例对象
     * @return 实例对象
     */
    @Override
    public Attractions insert(Attractions attractions) {
        this.attractionsDao.insert(attractions);
        return attractions;
    }

    /**
     * 修改数据
     *
     * @param attractions 实例对象
     * @return 实例对象
     */
    @Override
    public Attractions update(Attractions attractions) {
        this.attractionsDao.update(attractions);
        return this.queryById(attractions.getAttractionsId());
    }

    /**
     * 通过主键删除数据
     *
     * @param attractionsId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer attractionsId) {
        return this.attractionsDao.deleteById(attractionsId) > 0;
    }
}